package androidx.recyclerview.widget;

import android.content.Context;
import android.graphics.PointF;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.appcompat.widget.ActivityChooserView.ActivityChooserViewAdapter;
import androidx.recyclerview.widget.RecyclerView.LayoutParams;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.j.b;
import androidx.recyclerview.widget.RecyclerView.o;
import androidx.recyclerview.widget.RecyclerView.s;
import androidx.recyclerview.widget.RecyclerView.t;
import java.util.List;
import o.mi$b;
import o.mq;
import o.mv;

public class LinearLayoutManager extends j implements mi$b, androidx.recyclerview.widget.RecyclerView.q.c {
    private int ʻ;
    private final a ʼ;
    private boolean ʽ;
    private boolean ˊ;
    SavedState ˊॱ;
    private boolean ˋ;
    int ˋॱ;
    private boolean ˎ;
    private d ˏ;
    boolean ˏॱ;
    int ͺ;
    private boolean ॱ;
    final c ॱˊ;
    int ॱॱ;
    mq ᐝ;

    @RestrictTo({androidx.annotation.RestrictTo.d.ˊ})
    public static class SavedState implements Parcelable {
        public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˏ(parcel);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ॱ(i);
            }

            public SavedState ˏ(Parcel parcel) {
                return new SavedState(parcel);
            }

            public SavedState[] ॱ(int i) {
                return new SavedState[i];
            }
        };
        boolean ˊ;
        int ˋ;
        int ॱ;

        SavedState(Parcel parcel) {
            boolean z = true;
            this.ˋ = parcel.readInt();
            this.ॱ = parcel.readInt();
            if (parcel.readInt() != 1) {
                z = false;
            }
            this.ˊ = z;
        }

        public SavedState(SavedState savedState) {
            this.ˋ = savedState.ˋ;
            this.ॱ = savedState.ॱ;
            this.ˊ = savedState.ˊ;
        }

        boolean ˋ() {
            return this.ˋ >= 0;
        }

        void ˏ() {
            this.ˋ = -1;
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeInt(this.ˋ);
            parcel.writeInt(this.ॱ);
            parcel.writeInt(this.ˊ ? 1 : 0);
        }
    }

    protected static class a {
        public int ˊ;
        public boolean ˎ;
        public boolean ˏ;
        public boolean ॱ;

        protected a() {
        }

        void ˎ() {
            this.ˊ = 0;
            this.ˎ = false;
            this.ˏ = false;
            this.ॱ = false;
        }
    }

    static class c {
        int ˊ;
        boolean ˋ;
        int ˎ;
        boolean ˏ;
        mq ॱ;

        c() {
            ˊ();
        }

        void ˊ() {
            this.ˎ = -1;
            this.ˊ = Integer.MIN_VALUE;
            this.ˋ = false;
            this.ˏ = false;
        }

        void ˏ() {
            int ˊ;
            if (this.ˋ) {
                ˊ = this.ॱ.ˊ();
            } else {
                ˊ = this.ॱ.ˏ();
            }
            this.ˊ = ˊ;
        }

        public String toString() {
            return "AnchorInfo{mPosition=" + this.ˎ + ", mCoordinate=" + this.ˊ + ", mLayoutFromEnd=" + this.ˋ + ", mValid=" + this.ˏ + '}';
        }

        boolean ˏ(View view, t tVar) {
            LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
            return !layoutParams.ॱ() && layoutParams.ʻ() >= 0 && layoutParams.ʻ() < tVar.ˏ();
        }

        public void ˏ(View view, int i) {
            int ˎ = this.ॱ.ˎ();
            if (ˎ >= 0) {
                ॱ(view, i);
                return;
            }
            this.ˎ = i;
            int ˊ;
            if (this.ˋ) {
                ˎ = (this.ॱ.ˊ() - ˎ) - this.ॱ.ॱ(view);
                this.ˊ = this.ॱ.ˊ() - ˎ;
                if (ˎ > 0) {
                    ˊ = this.ˊ - this.ॱ.ˊ(view);
                    int ˏ = this.ॱ.ˏ();
                    ˊ -= ˏ + Math.min(this.ॱ.ˋ(view) - ˏ, 0);
                    if (ˊ < 0) {
                        this.ˊ = Math.min(ˎ, -ˊ) + this.ˊ;
                        return;
                    }
                    return;
                }
                return;
            }
            ˊ = this.ॱ.ˋ(view);
            ˏ = ˊ - this.ॱ.ˏ();
            this.ˊ = ˊ;
            if (ˏ > 0) {
                ˎ = (this.ॱ.ˊ() - Math.min(0, (this.ॱ.ˊ() - ˎ) - this.ॱ.ॱ(view))) - (ˊ + this.ॱ.ˊ(view));
                if (ˎ < 0) {
                    this.ˊ -= Math.min(ˏ, -ˎ);
                }
            }
        }

        public void ॱ(View view, int i) {
            if (this.ˋ) {
                this.ˊ = this.ॱ.ॱ(view) + this.ॱ.ˎ();
            } else {
                this.ˊ = this.ॱ.ˋ(view);
            }
            this.ˎ = i;
        }
    }

    static class d {
        int ʻ = 0;
        int ʼ;
        boolean ʽ = false;
        int ˊ;
        boolean ˋ = true;
        boolean ˋॱ;
        int ˎ;
        int ˏ;
        int ॱ;
        List<s> ॱˊ = null;
        int ॱॱ;
        int ᐝ;

        d() {
        }

        boolean ˊ(t tVar) {
            return this.ˏ >= 0 && this.ˏ < tVar.ˏ();
        }

        View ˊ(o oVar) {
            if (this.ॱˊ != null) {
                return ˏ();
            }
            View ˊ = oVar.ˊ(this.ˏ);
            this.ˏ += this.ˎ;
            return ˊ;
        }

        private View ˏ() {
            int size = this.ॱˊ.size();
            for (int i = 0; i < size; i++) {
                View view = ((s) this.ॱˊ.get(i)).ˊ;
                LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
                if (!layoutParams.ॱ() && this.ˏ == layoutParams.ʻ()) {
                    ॱ(view);
                    return view;
                }
            }
            return null;
        }

        public void ॱ() {
            ॱ(null);
        }

        public void ॱ(View view) {
            View ˋ = ˋ(view);
            if (ˋ == null) {
                this.ˏ = -1;
            } else {
                this.ˏ = ((LayoutParams) ˋ.getLayoutParams()).ʻ();
            }
        }

        public View ˋ(View view) {
            int size = this.ॱˊ.size();
            View view2 = null;
            int i = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            int i2 = 0;
            while (i2 < size) {
                int i3;
                View view3;
                View view4 = ((s) this.ॱˊ.get(i2)).ˊ;
                LayoutParams layoutParams = (LayoutParams) view4.getLayoutParams();
                if (view4 != view) {
                    if (layoutParams.ॱ()) {
                        i3 = i;
                        view3 = view2;
                    } else {
                        i3 = (layoutParams.ʻ() - this.ˏ) * this.ˎ;
                        if (i3 < 0) {
                            i3 = i;
                            view3 = view2;
                        } else if (i3 < i) {
                            if (i3 == 0) {
                                return view4;
                            }
                            view3 = view4;
                        }
                    }
                    i2++;
                    view2 = view3;
                    i = i3;
                }
                i3 = i;
                view3 = view2;
                i2++;
                view2 = view3;
                i = i3;
            }
            return view2;
        }
    }

    public LinearLayoutManager(Context context) {
        this(context, 1, false);
    }

    public LinearLayoutManager(Context context, int i, boolean z) {
        this.ॱॱ = 1;
        this.ॱ = false;
        this.ˏॱ = false;
        this.ˎ = false;
        this.ˋ = true;
        this.ͺ = -1;
        this.ˋॱ = Integer.MIN_VALUE;
        this.ˊॱ = null;
        this.ॱˊ = new c();
        this.ʼ = new a();
        this.ʻ = 2;
        ˊ(i);
        ˊ(z);
    }

    public LinearLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) {
        this.ॱॱ = 1;
        this.ॱ = false;
        this.ˏॱ = false;
        this.ˎ = false;
        this.ˋ = true;
        this.ͺ = -1;
        this.ˋॱ = Integer.MIN_VALUE;
        this.ˊॱ = null;
        this.ॱˊ = new c();
        this.ʼ = new a();
        this.ʻ = 2;
        androidx.recyclerview.widget.RecyclerView.j.a ॱ = j.ॱ(context, attributeSet, i, i2);
        ˊ(ॱ.ˋ);
        ˊ(ॱ.ˊ);
        ˋ(ॱ.ˎ);
    }

    public boolean ˋ() {
        return true;
    }

    public LayoutParams ॱ() {
        return new LayoutParams(-2, -2);
    }

    public void ˊ(RecyclerView recyclerView, o oVar) {
        super.ˊ(recyclerView, oVar);
        if (this.ʽ) {
            ˏ(oVar);
            oVar.ˋ();
        }
    }

    public void ˊ(AccessibilityEvent accessibilityEvent) {
        super.ˊ(accessibilityEvent);
        if (ˈ() > 0) {
            accessibilityEvent.setFromIndex(ॱˊ());
            accessibilityEvent.setToIndex(ʻॱ());
        }
    }

    public Parcelable ˊ() {
        if (this.ˊॱ != null) {
            return new SavedState(this.ˊॱ);
        }
        Parcelable savedState = new SavedState();
        if (ˈ() > 0) {
            ᐝ();
            boolean z = this.ˊ ^ this.ˏॱ;
            savedState.ˊ = z;
            View ـ;
            if (z) {
                ـ = ـ();
                savedState.ॱ = this.ᐝ.ˊ() - this.ᐝ.ॱ(ـ);
                savedState.ˋ = ˎ(ـ);
                return savedState;
            }
            ـ = ॱʽ();
            savedState.ˋ = ˎ(ـ);
            savedState.ॱ = this.ᐝ.ˋ(ـ) - this.ᐝ.ˏ();
            return savedState;
        }
        savedState.ˏ();
        return savedState;
    }

    public void ॱ(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            this.ˊॱ = (SavedState) parcelable;
            ॱˋ();
        }
    }

    public boolean ʻ() {
        return this.ॱॱ == 0;
    }

    public boolean ʼ() {
        return this.ॱॱ == 1;
    }

    public void ˋ(boolean z) {
        ˎ(null);
        if (this.ˎ != z) {
            this.ˎ = z;
            ॱˋ();
        }
    }

    public int ॱॱ() {
        return this.ॱॱ;
    }

    public void ˊ(int i) {
        if (i == 0 || i == 1) {
            ˎ(null);
            if (i != this.ॱॱ || this.ᐝ == null) {
                this.ᐝ = mq.ˊ(this, i);
                this.ॱˊ.ॱ = this.ᐝ;
                this.ॱॱ = i;
                ॱˋ();
                return;
            }
            return;
        }
        throw new IllegalArgumentException("invalid orientation:" + i);
    }

    private void ˎ() {
        boolean z = true;
        if (this.ॱॱ == 1 || !ʽ()) {
            this.ˏॱ = this.ॱ;
            return;
        }
        if (this.ॱ) {
            z = false;
        }
        this.ˏॱ = z;
    }

    public void ˊ(boolean z) {
        ˎ(null);
        if (z != this.ॱ) {
            this.ॱ = z;
            ॱˋ();
        }
    }

    public View ˋ(int i) {
        int ˈ = ˈ();
        if (ˈ == 0) {
            return null;
        }
        int ˎ = i - ˎ(ᐝ(0));
        if (ˎ >= 0 && ˎ < ˈ) {
            View ᐝ = ᐝ(ˎ);
            if (ˎ(ᐝ) == i) {
                return ᐝ;
            }
        }
        return super.ˋ(i);
    }

    protected int ˏ(t tVar) {
        if (tVar.ॱ()) {
            return this.ᐝ.ʻ();
        }
        return 0;
    }

    public PointF ˎ(int i) {
        int i2 = 1;
        boolean z = false;
        if (ˈ() == 0) {
            return null;
        }
        if (i < ˎ(ᐝ(0))) {
            z = true;
        }
        if (z != this.ˏॱ) {
            i2 = -1;
        }
        if (this.ॱॱ == 0) {
            return new PointF((float) i2, 0.0f);
        }
        return new PointF(0.0f, (float) i2);
    }

    public void ˋ(o oVar, t tVar) {
        int i = -1;
        if (!(this.ˊॱ == null && this.ͺ == -1) && tVar.ˏ() == 0) {
            ˏ(oVar);
            return;
        }
        int i2;
        int ˊ;
        if (this.ˊॱ != null && this.ˊॱ.ˋ()) {
            this.ͺ = this.ˊॱ.ˋ;
        }
        ᐝ();
        this.ˏ.ˋ = false;
        ˎ();
        View ˎˎ = ˎˎ();
        if (!this.ॱˊ.ˏ || this.ͺ != -1 || this.ˊॱ != null) {
            this.ॱˊ.ˊ();
            this.ॱˊ.ˋ = this.ˏॱ ^ this.ˎ;
            ˏ(oVar, tVar, this.ॱˊ);
            this.ॱˊ.ˏ = true;
        } else if (ˎˎ != null && (this.ᐝ.ˋ(ˎˎ) >= this.ᐝ.ˊ() || this.ᐝ.ॱ(ˎˎ) <= this.ᐝ.ˏ())) {
            this.ॱˊ.ˏ(ˎˎ, ˎ(ˎˎ));
        }
        int ˏ = ˏ(tVar);
        if (this.ˏ.ʼ >= 0) {
            i2 = 0;
        } else {
            i2 = ˏ;
            ˏ = 0;
        }
        i2 += this.ᐝ.ˏ();
        ˏ += this.ᐝ.ʼ();
        if (!(!tVar.ˋ() || this.ͺ == -1 || this.ˋॱ == Integer.MIN_VALUE)) {
            View ˋ = ˋ(this.ͺ);
            if (ˋ != null) {
                if (this.ˏॱ) {
                    ˊ = (this.ᐝ.ˊ() - this.ᐝ.ॱ(ˋ)) - this.ˋॱ;
                } else {
                    ˊ = this.ˋॱ - (this.ᐝ.ˋ(ˋ) - this.ᐝ.ˏ());
                }
                if (ˊ > 0) {
                    i2 += ˊ;
                } else {
                    ˏ -= ˊ;
                }
            }
        }
        if (this.ॱˊ.ˋ) {
            if (this.ˏॱ) {
                i = 1;
            }
        } else if (!this.ˏॱ) {
            i = 1;
        }
        ˎ(oVar, tVar, this.ॱˊ, i);
        ˎ(oVar);
        this.ˏ.ˋॱ = ˋॱ();
        this.ˏ.ʽ = tVar.ˋ();
        if (this.ॱˊ.ˋ) {
            ˎ(this.ॱˊ);
            this.ˏ.ʻ = i2;
            ॱ(oVar, this.ˏ, tVar, false);
            i2 = this.ˏ.ˊ;
            ˊ = this.ˏ.ˏ;
            if (this.ˏ.ॱ > 0) {
                ˏ += this.ˏ.ॱ;
            }
            ˏ(this.ॱˊ);
            this.ˏ.ʻ = ˏ;
            d dVar = this.ˏ;
            dVar.ˏ += this.ˏ.ˎ;
            ॱ(oVar, this.ˏ, tVar, false);
            i = this.ˏ.ˊ;
            if (this.ˏ.ॱ > 0) {
                ˏ = this.ˏ.ॱ;
                ᐝ(ˊ, i2);
                this.ˏ.ʻ = ˏ;
                ॱ(oVar, this.ˏ, tVar, false);
                ˏ = this.ˏ.ˊ;
            } else {
                ˏ = i2;
            }
            i2 = ˏ;
            ˏ = i;
        } else {
            ˏ(this.ॱˊ);
            this.ˏ.ʻ = ˏ;
            ॱ(oVar, this.ˏ, tVar, false);
            ˏ = this.ˏ.ˊ;
            i = this.ˏ.ˏ;
            if (this.ˏ.ॱ > 0) {
                i2 += this.ˏ.ॱ;
            }
            ˎ(this.ॱˊ);
            this.ˏ.ʻ = i2;
            d dVar2 = this.ˏ;
            dVar2.ˏ += this.ˏ.ˎ;
            ॱ(oVar, this.ˏ, tVar, false);
            i2 = this.ˏ.ˊ;
            if (this.ˏ.ॱ > 0) {
                ˊ = this.ˏ.ॱ;
                ˎ(i, ˏ);
                this.ˏ.ʻ = ˊ;
                ॱ(oVar, this.ˏ, tVar, false);
                ˏ = this.ˏ.ˊ;
            }
        }
        if (ˈ() > 0) {
            int ˋ2;
            if ((this.ˏॱ ^ this.ˎ) != 0) {
                i = ॱ(ˏ, oVar, tVar, true);
                i2 += i;
                ˏ += i;
                ˋ2 = ˋ(i2, oVar, tVar, false);
                i2 += ˋ2;
                ˏ += ˋ2;
            } else {
                i = ˋ(i2, oVar, tVar, true);
                i2 += i;
                ˏ += i;
                ˋ2 = ॱ(ˏ, oVar, tVar, false);
                i2 += ˋ2;
                ˏ += ˋ2;
            }
        }
        ˋ(oVar, tVar, i2, ˏ);
        if (tVar.ˋ()) {
            this.ॱˊ.ˊ();
        } else {
            this.ᐝ.ˋ();
        }
        this.ˊ = this.ˎ;
    }

    public void ˋ(t tVar) {
        super.ˋ(tVar);
        this.ˊॱ = null;
        this.ͺ = -1;
        this.ˋॱ = Integer.MIN_VALUE;
        this.ॱˊ.ˊ();
    }

    void ˎ(o oVar, t tVar, c cVar, int i) {
    }

    private void ˋ(o oVar, t tVar, int i, int i2) {
        if (tVar.ˎ() && ˈ() != 0 && !tVar.ˋ() && ˏ()) {
            int i3 = 0;
            int i4 = 0;
            List ॱ = oVar.ॱ();
            int size = ॱ.size();
            int ˎ = ˎ(ᐝ(0));
            int i5 = 0;
            while (i5 < size) {
                int i6;
                int i7;
                s sVar = (s) ॱ.get(i5);
                if (sVar.ʻॱ()) {
                    i6 = i4;
                    i7 = i3;
                } else {
                    if (((sVar.ˏ() < ˎ) != this.ˏॱ ? -1 : 1) == -1) {
                        i7 = this.ᐝ.ˊ(sVar.ˊ) + i3;
                        i6 = i4;
                    } else {
                        i6 = this.ᐝ.ˊ(sVar.ˊ) + i4;
                        i7 = i3;
                    }
                }
                i5++;
                i3 = i7;
                i4 = i6;
            }
            this.ˏ.ॱˊ = ॱ;
            if (i3 > 0) {
                ᐝ(ˎ(ॱʽ()), i);
                this.ˏ.ʻ = i3;
                this.ˏ.ॱ = 0;
                this.ˏ.ॱ();
                ॱ(oVar, this.ˏ, tVar, false);
            }
            if (i4 > 0) {
                ˎ(ˎ(ـ()), i2);
                this.ˏ.ʻ = i4;
                this.ˏ.ॱ = 0;
                this.ˏ.ॱ();
                ॱ(oVar, this.ˏ, tVar, false);
            }
            this.ˏ.ॱˊ = null;
        }
    }

    private void ˏ(o oVar, t tVar, c cVar) {
        if (!ˎ(tVar, cVar) && !ˋ(oVar, tVar, cVar)) {
            cVar.ˏ();
            cVar.ˎ = this.ˎ ? tVar.ˏ() - 1 : 0;
        }
    }

    private boolean ˋ(o oVar, t tVar, c cVar) {
        boolean z = false;
        if (ˈ() == 0) {
            return false;
        }
        View ˎˎ = ˎˎ();
        if (ˎˎ != null && cVar.ˏ(ˎˎ, tVar)) {
            cVar.ˏ(ˎˎ, ˎ(ˎˎ));
            return true;
        } else if (this.ˊ != this.ˎ) {
            return false;
        } else {
            if (cVar.ˋ) {
                ˎˎ = ॱॱ(oVar, tVar);
            } else {
                ˎˎ = ʼ(oVar, tVar);
            }
            if (ˎˎ == null) {
                return false;
            }
            cVar.ॱ(ˎˎ, ˎ(ˎˎ));
            if (!tVar.ˋ() && ˏ()) {
                if (this.ᐝ.ˋ(ˎˎ) >= this.ᐝ.ˊ() || this.ᐝ.ॱ(ˎˎ) < this.ᐝ.ˏ()) {
                    z = true;
                }
                if (z) {
                    int ˊ;
                    if (cVar.ˋ) {
                        ˊ = this.ᐝ.ˊ();
                    } else {
                        ˊ = this.ᐝ.ˏ();
                    }
                    cVar.ˊ = ˊ;
                }
            }
            return true;
        }
    }

    private boolean ˎ(t tVar, c cVar) {
        boolean z = false;
        if (tVar.ˋ() || this.ͺ == -1) {
            return false;
        }
        if (this.ͺ < 0 || this.ͺ >= tVar.ˏ()) {
            this.ͺ = -1;
            this.ˋॱ = Integer.MIN_VALUE;
            return false;
        }
        cVar.ˎ = this.ͺ;
        if (this.ˊॱ != null && this.ˊॱ.ˋ()) {
            cVar.ˋ = this.ˊॱ.ˊ;
            if (cVar.ˋ) {
                cVar.ˊ = this.ᐝ.ˊ() - this.ˊॱ.ॱ;
                return true;
            }
            cVar.ˊ = this.ᐝ.ˏ() + this.ˊॱ.ॱ;
            return true;
        } else if (this.ˋॱ == Integer.MIN_VALUE) {
            View ˋ = ˋ(this.ͺ);
            if (ˋ == null) {
                if (ˈ() > 0) {
                    boolean z2;
                    if (this.ͺ < ˎ(ᐝ(0))) {
                        z2 = true;
                    } else {
                        z2 = false;
                    }
                    if (z2 == this.ˏॱ) {
                        z = true;
                    }
                    cVar.ˋ = z;
                }
                cVar.ˏ();
                return true;
            } else if (this.ᐝ.ˊ(ˋ) > this.ᐝ.ʻ()) {
                cVar.ˏ();
                return true;
            } else if (this.ᐝ.ˋ(ˋ) - this.ᐝ.ˏ() < 0) {
                cVar.ˊ = this.ᐝ.ˏ();
                cVar.ˋ = false;
                return true;
            } else if (this.ᐝ.ˊ() - this.ᐝ.ॱ(ˋ) < 0) {
                cVar.ˊ = this.ᐝ.ˊ();
                cVar.ˋ = true;
                return true;
            } else {
                int ॱ;
                if (cVar.ˋ) {
                    ॱ = this.ᐝ.ॱ(ˋ) + this.ᐝ.ˎ();
                } else {
                    ॱ = this.ᐝ.ˋ(ˋ);
                }
                cVar.ˊ = ॱ;
                return true;
            }
        } else {
            cVar.ˋ = this.ˏॱ;
            if (this.ˏॱ) {
                cVar.ˊ = this.ᐝ.ˊ() - this.ˋॱ;
                return true;
            }
            cVar.ˊ = this.ᐝ.ˏ() + this.ˋॱ;
            return true;
        }
    }

    private int ॱ(int i, o oVar, t tVar, boolean z) {
        int ˊ = this.ᐝ.ˊ() - i;
        if (ˊ <= 0) {
            return 0;
        }
        ˊ = -ˋ(-ˊ, oVar, tVar);
        int i2 = i + ˊ;
        if (!z) {
            return ˊ;
        }
        i2 = this.ᐝ.ˊ() - i2;
        if (i2 <= 0) {
            return ˊ;
        }
        this.ᐝ.ˋ(i2);
        return ˊ + i2;
    }

    private int ˋ(int i, o oVar, t tVar, boolean z) {
        int ˏ = i - this.ᐝ.ˏ();
        if (ˏ <= 0) {
            return 0;
        }
        ˏ = -ˋ(ˏ, oVar, tVar);
        int i2 = i + ˏ;
        if (!z) {
            return ˏ;
        }
        i2 -= this.ᐝ.ˏ();
        if (i2 <= 0) {
            return ˏ;
        }
        this.ᐝ.ˋ(-i2);
        return ˏ - i2;
    }

    private void ˏ(c cVar) {
        ˎ(cVar.ˎ, cVar.ˊ);
    }

    private void ˎ(int i, int i2) {
        this.ˏ.ॱ = this.ᐝ.ˊ() - i2;
        this.ˏ.ˎ = this.ˏॱ ? -1 : 1;
        this.ˏ.ˏ = i;
        this.ˏ.ᐝ = 1;
        this.ˏ.ˊ = i2;
        this.ˏ.ॱॱ = Integer.MIN_VALUE;
    }

    private void ˎ(c cVar) {
        ᐝ(cVar.ˎ, cVar.ˊ);
    }

    private void ᐝ(int i, int i2) {
        this.ˏ.ॱ = i2 - this.ᐝ.ˏ();
        this.ˏ.ˏ = i;
        this.ˏ.ˎ = this.ˏॱ ? 1 : -1;
        this.ˏ.ᐝ = -1;
        this.ˏ.ˊ = i2;
        this.ˏ.ॱॱ = Integer.MIN_VALUE;
    }

    protected boolean ʽ() {
        return ʽॱ() == 1;
    }

    void ᐝ() {
        if (this.ˏ == null) {
            this.ˏ = ͺ();
        }
    }

    d ͺ() {
        return new d();
    }

    public void ˏ(int i) {
        this.ͺ = i;
        this.ˋॱ = Integer.MIN_VALUE;
        if (this.ˊॱ != null) {
            this.ˊॱ.ˏ();
        }
        ॱˋ();
    }

    public void ॱ(int i, int i2) {
        this.ͺ = i;
        this.ˋॱ = i2;
        if (this.ˊॱ != null) {
            this.ˊॱ.ˏ();
        }
        ॱˋ();
    }

    public int ˊ(int i, o oVar, t tVar) {
        if (this.ॱॱ == 1) {
            return 0;
        }
        return ˋ(i, oVar, tVar);
    }

    public int ˎ(int i, o oVar, t tVar) {
        if (this.ॱॱ == 0) {
            return 0;
        }
        return ˋ(i, oVar, tVar);
    }

    public int ॱ(t tVar) {
        return ᐝ(tVar);
    }

    public int ˊ(t tVar) {
        return ᐝ(tVar);
    }

    public int ˎ(t tVar) {
        return ॱॱ(tVar);
    }

    public int ʽ(t tVar) {
        return ॱॱ(tVar);
    }

    public int ʼ(t tVar) {
        return ॱˊ(tVar);
    }

    public int ʻ(t tVar) {
        return ॱˊ(tVar);
    }

    private int ᐝ(t tVar) {
        boolean z = false;
        if (ˈ() == 0) {
            return 0;
        }
        ᐝ();
        mq mqVar = this.ᐝ;
        View ॱ = ॱ(!this.ˋ, true);
        if (!this.ˋ) {
            z = true;
        }
        return mv.ˋ(tVar, mqVar, ॱ, ˊ(z, true), this, this.ˋ, this.ˏॱ);
    }

    private int ॱॱ(t tVar) {
        boolean z = false;
        if (ˈ() == 0) {
            return 0;
        }
        ᐝ();
        mq mqVar = this.ᐝ;
        View ॱ = ॱ(!this.ˋ, true);
        if (!this.ˋ) {
            z = true;
        }
        return mv.ॱ(tVar, mqVar, ॱ, ˊ(z, true), this, this.ˋ);
    }

    private int ॱˊ(t tVar) {
        boolean z = false;
        if (ˈ() == 0) {
            return 0;
        }
        ᐝ();
        mq mqVar = this.ᐝ;
        View ॱ = ॱ(!this.ˋ, true);
        if (!this.ˋ) {
            z = true;
        }
        return mv.ˎ(tVar, mqVar, ॱ, ˊ(z, true), this, this.ˋ);
    }

    private void ॱ(int i, int i2, boolean z, t tVar) {
        int i3 = -1;
        int i4 = 1;
        this.ˏ.ˋॱ = ˋॱ();
        this.ˏ.ʻ = ˏ(tVar);
        this.ˏ.ᐝ = i;
        View ـ;
        d dVar;
        if (i == 1) {
            d dVar2 = this.ˏ;
            dVar2.ʻ += this.ᐝ.ʼ();
            ـ = ـ();
            dVar = this.ˏ;
            if (!this.ˏॱ) {
                i3 = 1;
            }
            dVar.ˎ = i3;
            this.ˏ.ˏ = ˎ(ـ) + this.ˏ.ˎ;
            this.ˏ.ˊ = this.ᐝ.ॱ(ـ);
            i3 = this.ᐝ.ॱ(ـ) - this.ᐝ.ˊ();
        } else {
            ـ = ॱʽ();
            dVar = this.ˏ;
            dVar.ʻ += this.ᐝ.ˏ();
            dVar = this.ˏ;
            if (!this.ˏॱ) {
                i4 = -1;
            }
            dVar.ˎ = i4;
            this.ˏ.ˏ = ˎ(ـ) + this.ˏ.ˎ;
            this.ˏ.ˊ = this.ᐝ.ˋ(ـ);
            i3 = (-this.ᐝ.ˋ(ـ)) + this.ᐝ.ˏ();
        }
        this.ˏ.ॱ = i2;
        if (z) {
            d dVar3 = this.ˏ;
            dVar3.ॱ -= i3;
        }
        this.ˏ.ॱॱ = i3;
    }

    boolean ˋॱ() {
        return this.ᐝ.ॱॱ() == 0 && this.ᐝ.ॱ() == 0;
    }

    void ˎ(t tVar, d dVar, b bVar) {
        int i = dVar.ˏ;
        if (i >= 0 && i < tVar.ˏ()) {
            bVar.ˎ(i, Math.max(0, dVar.ॱॱ));
        }
    }

    public void ˋ(int i, b bVar) {
        int i2;
        boolean z;
        if (this.ˊॱ == null || !this.ˊॱ.ˋ()) {
            ˎ();
            boolean z2 = this.ˏॱ;
            if (this.ͺ == -1) {
                i2 = z2 ? i - 1 : 0;
                z = z2;
            } else {
                i2 = this.ͺ;
                z = z2;
            }
        } else {
            z = this.ˊॱ.ˊ;
            i2 = this.ˊॱ.ˋ;
        }
        int i3 = z ? -1 : 1;
        for (int i4 = 0; i4 < this.ʻ && i2 >= 0 && i2 < i; i4++) {
            bVar.ˎ(i2, 0);
            i2 += i3;
        }
    }

    public void ˊ(int i, int i2, t tVar, b bVar) {
        if (this.ॱॱ != 0) {
            i = i2;
        }
        if (ˈ() != 0 && i != 0) {
            ᐝ();
            ॱ(i > 0 ? 1 : -1, Math.abs(i), true, tVar);
            ˎ(tVar, this.ˏ, bVar);
        }
    }

    int ˋ(int i, o oVar, t tVar) {
        if (ˈ() == 0 || i == 0) {
            return 0;
        }
        this.ˏ.ˋ = true;
        ᐝ();
        int i2 = i > 0 ? 1 : -1;
        int abs = Math.abs(i);
        ॱ(i2, abs, true, tVar);
        int ॱ = this.ˏ.ॱॱ + ॱ(oVar, this.ˏ, tVar, false);
        if (ॱ < 0) {
            return 0;
        }
        if (abs > ॱ) {
            i = i2 * ॱ;
        }
        this.ᐝ.ˋ(-i);
        this.ˏ.ʼ = i;
        return i;
    }

    public void ˎ(String str) {
        if (this.ˊॱ == null) {
            super.ˎ(str);
        }
    }

    private void ˏ(o oVar, int i, int i2) {
        if (i != i2) {
            if (i2 > i) {
                for (int i3 = i2 - 1; i3 >= i; i3--) {
                    ˊ(i3, oVar);
                }
                return;
            }
            while (i > i2) {
                ˊ(i, oVar);
                i--;
            }
        }
    }

    private void ॱ(o oVar, int i) {
        if (i >= 0) {
            int ˈ = ˈ();
            int i2;
            if (this.ˏॱ) {
                for (i2 = ˈ - 1; i2 >= 0; i2--) {
                    View ᐝ = ᐝ(i2);
                    if (this.ᐝ.ॱ(ᐝ) > i || this.ᐝ.ˏ(ᐝ) > i) {
                        ˏ(oVar, ˈ - 1, i2);
                        return;
                    }
                }
                return;
            }
            for (i2 = 0; i2 < ˈ; i2++) {
                View ᐝ2 = ᐝ(i2);
                if (this.ᐝ.ॱ(ᐝ2) > i || this.ᐝ.ˏ(ᐝ2) > i) {
                    ˏ(oVar, 0, i2);
                    return;
                }
            }
        }
    }

    private void ˎ(o oVar, int i) {
        int ˈ = ˈ();
        if (i >= 0) {
            int ॱ = this.ᐝ.ॱ() - i;
            int i2;
            if (this.ˏॱ) {
                for (i2 = 0; i2 < ˈ; i2++) {
                    View ᐝ = ᐝ(i2);
                    if (this.ᐝ.ˋ(ᐝ) < ॱ || this.ᐝ.ˎ(ᐝ) < ॱ) {
                        ˏ(oVar, 0, i2);
                        return;
                    }
                }
                return;
            }
            for (i2 = ˈ - 1; i2 >= 0; i2--) {
                View ᐝ2 = ᐝ(i2);
                if (this.ᐝ.ˋ(ᐝ2) < ॱ || this.ᐝ.ˎ(ᐝ2) < ॱ) {
                    ˏ(oVar, ˈ - 1, i2);
                    return;
                }
            }
        }
    }

    private void ˋ(o oVar, d dVar) {
        if (dVar.ˋ && !dVar.ˋॱ) {
            if (dVar.ᐝ == -1) {
                ˎ(oVar, dVar.ॱॱ);
            } else {
                ॱ(oVar, dVar.ॱॱ);
            }
        }
    }

    int ॱ(o oVar, d dVar, t tVar, boolean z) {
        int i = dVar.ॱ;
        if (dVar.ॱॱ != Integer.MIN_VALUE) {
            if (dVar.ॱ < 0) {
                dVar.ॱॱ += dVar.ॱ;
            }
            ˋ(oVar, dVar);
        }
        int i2 = dVar.ॱ + dVar.ʻ;
        a aVar = this.ʼ;
        while (true) {
            if ((!dVar.ˋॱ && i2 <= 0) || !dVar.ˊ(tVar)) {
                break;
            }
            aVar.ˎ();
            ˎ(oVar, tVar, dVar, aVar);
            if (!aVar.ˎ) {
                dVar.ˊ += aVar.ˊ * dVar.ᐝ;
                if (!(aVar.ˏ && this.ˏ.ॱˊ == null && tVar.ˋ())) {
                    dVar.ॱ -= aVar.ˊ;
                    i2 -= aVar.ˊ;
                }
                if (dVar.ॱॱ != Integer.MIN_VALUE) {
                    dVar.ॱॱ += aVar.ˊ;
                    if (dVar.ॱ < 0) {
                        dVar.ॱॱ += dVar.ॱ;
                    }
                    ˋ(oVar, dVar);
                }
                if (z && aVar.ॱ) {
                    break;
                }
            } else {
                break;
            }
        }
        return i - dVar.ॱ;
    }

    void ˎ(o oVar, t tVar, d dVar, a aVar) {
        View ˊ = dVar.ˊ(oVar);
        if (ˊ == null) {
            aVar.ˎ = true;
            return;
        }
        int ᐝ;
        int i;
        int i2;
        int i3;
        LayoutParams layoutParams = (LayoutParams) ˊ.getLayoutParams();
        if (dVar.ॱˊ == null) {
            if (this.ˏॱ == (dVar.ᐝ == -1)) {
                ˊ(ˊ);
            } else {
                ˊ(ˊ, 0);
            }
        } else {
            boolean z;
            boolean z2 = this.ˏॱ;
            if (dVar.ᐝ == -1) {
                z = true;
            } else {
                z = false;
            }
            if (z2 == z) {
                ॱ(ˊ);
            } else {
                ˏ(ˊ, 0);
            }
        }
        ˊ(ˊ, 0, 0);
        aVar.ˊ = this.ᐝ.ˊ(ˊ);
        if (this.ॱॱ == 1) {
            int ˋˊ;
            if (ʽ()) {
                ˋˊ = ˋˊ() - ˋᐝ();
                ᐝ = ˋˊ - this.ᐝ.ᐝ(ˊ);
            } else {
                ᐝ = ˊˊ();
                ˋˊ = this.ᐝ.ᐝ(ˊ) + ᐝ;
            }
            if (dVar.ᐝ == -1) {
                i = dVar.ˊ;
                i2 = dVar.ˊ - aVar.ˊ;
                i3 = ˋˊ;
            } else {
                i2 = dVar.ˊ;
                i = aVar.ˊ + dVar.ˊ;
                i3 = ˋˊ;
            }
        } else {
            i2 = ˋˋ();
            i = i2 + this.ᐝ.ᐝ(ˊ);
            if (dVar.ᐝ == -1) {
                ᐝ = dVar.ˊ - aVar.ˊ;
                i3 = dVar.ˊ;
            } else {
                ᐝ = dVar.ˊ;
                i3 = dVar.ˊ + aVar.ˊ;
            }
        }
        ˋ(ˊ, ᐝ, i2, i3, i);
        if (layoutParams.ॱ() || layoutParams.ˎ()) {
            aVar.ˏ = true;
        }
        aVar.ॱ = ˊ.hasFocusable();
    }

    boolean ˏॱ() {
        return (ˊᐝ() == 1073741824 || ˊˋ() == 1073741824 || !ˏˏ()) ? false : true;
    }

    int ʽ(int i) {
        int i2 = Integer.MIN_VALUE;
        int i3 = 1;
        switch (i) {
            case 1:
                if (this.ॱॱ == 1 || !ʽ()) {
                    return -1;
                }
                return 1;
            case 2:
                if (this.ॱॱ == 1) {
                    return 1;
                }
                if (ʽ()) {
                    return -1;
                }
                return 1;
            case 17:
                if (this.ॱॱ != 0) {
                    return Integer.MIN_VALUE;
                }
                return -1;
            case 33:
                if (this.ॱॱ != 1) {
                    return Integer.MIN_VALUE;
                }
                return -1;
            case o.fc.c.ꓸॱ /*66*/:
                if (this.ॱॱ != 0) {
                    i3 = Integer.MIN_VALUE;
                }
                return i3;
            case 130:
                if (this.ॱॱ == 1) {
                    i2 = 1;
                }
                return i2;
            default:
                return Integer.MIN_VALUE;
        }
    }

    private View ॱʽ() {
        return ᐝ(this.ˏॱ ? ˈ() - 1 : 0);
    }

    private View ـ() {
        return ᐝ(this.ˏॱ ? 0 : ˈ() - 1);
    }

    private View ॱ(boolean z, boolean z2) {
        if (this.ˏॱ) {
            return ॱ(ˈ() - 1, -1, z, z2);
        }
        return ॱ(0, ˈ(), z, z2);
    }

    private View ˊ(boolean z, boolean z2) {
        if (this.ˏॱ) {
            return ॱ(0, ˈ(), z, z2);
        }
        return ॱ(ˈ() - 1, -1, z, z2);
    }

    private View ॱॱ(o oVar, t tVar) {
        if (this.ˏॱ) {
            return ʽ(oVar, tVar);
        }
        return ᐝ(oVar, tVar);
    }

    private View ʼ(o oVar, t tVar) {
        if (this.ˏॱ) {
            return ᐝ(oVar, tVar);
        }
        return ʽ(oVar, tVar);
    }

    private View ʽ(o oVar, t tVar) {
        return ˎ(oVar, tVar, 0, ˈ(), tVar.ˏ());
    }

    private View ᐝ(o oVar, t tVar) {
        return ˎ(oVar, tVar, ˈ() - 1, -1, tVar.ˏ());
    }

    View ˎ(o oVar, t tVar, int i, int i2, int i3) {
        View view = null;
        ᐝ();
        int ˏ = this.ᐝ.ˏ();
        int ˊ = this.ᐝ.ˊ();
        int i4 = i2 > i ? 1 : -1;
        View view2 = null;
        while (i != i2) {
            View view3;
            View ᐝ = ᐝ(i);
            int ˎ = ˎ(ᐝ);
            if (ˎ >= 0 && ˎ < i3) {
                if (((LayoutParams) ᐝ.getLayoutParams()).ॱ()) {
                    if (view2 == null) {
                        view3 = view;
                        i += i4;
                        view = view3;
                        view2 = ᐝ;
                    }
                } else if (this.ᐝ.ˋ(ᐝ) < ˊ && this.ᐝ.ॱ(ᐝ) >= ˏ) {
                    return ᐝ;
                } else {
                    if (view == null) {
                        view3 = ᐝ;
                        ᐝ = view2;
                        i += i4;
                        view = view3;
                        view2 = ᐝ;
                    }
                }
            }
            view3 = view;
            ᐝ = view2;
            i += i4;
            view = view3;
            view2 = ᐝ;
        }
        if (view == null) {
            view = view2;
        }
        return view;
    }

    private View ʻ(o oVar, t tVar) {
        if (this.ˏॱ) {
            return ͺ(oVar, tVar);
        }
        return ॱˊ(oVar, tVar);
    }

    private View ˋॱ(o oVar, t tVar) {
        if (this.ˏॱ) {
            return ॱˊ(oVar, tVar);
        }
        return ͺ(oVar, tVar);
    }

    private View ͺ(o oVar, t tVar) {
        return ˊ(0, ˈ());
    }

    private View ॱˊ(o oVar, t tVar) {
        return ˊ(ˈ() - 1, -1);
    }

    public int ॱˊ() {
        View ॱ = ॱ(0, ˈ(), false, true);
        return ॱ == null ? -1 : ˎ(ॱ);
    }

    public int ˊॱ() {
        View ॱ = ॱ(0, ˈ(), true, false);
        return ॱ == null ? -1 : ˎ(ॱ);
    }

    public int ʻॱ() {
        View ॱ = ॱ(ˈ() - 1, -1, false, true);
        if (ॱ == null) {
            return -1;
        }
        return ˎ(ॱ);
    }

    public int ॱˎ() {
        View ॱ = ॱ(ˈ() - 1, -1, true, false);
        if (ॱ == null) {
            return -1;
        }
        return ˎ(ॱ);
    }

    View ॱ(int i, int i2, boolean z, boolean z2) {
        int i3;
        int i4 = 320;
        ᐝ();
        if (z) {
            i3 = 24579;
        } else {
            i3 = 320;
        }
        if (!z2) {
            i4 = 0;
        }
        if (this.ॱॱ == 0) {
            return this.ॱᐝ.ॱ(i, i2, i3, i4);
        }
        return this.ॱˋ.ॱ(i, i2, i3, i4);
    }

    View ˊ(int i, int i2) {
        ᐝ();
        Object obj = i2 > i ? 1 : i2 < i ? -1 : null;
        if (obj == null) {
            return ᐝ(i);
        }
        int i3;
        int i4;
        if (this.ᐝ.ˋ(ᐝ(i)) < this.ᐝ.ˏ()) {
            i3 = 16644;
            i4 = 16388;
        } else {
            i3 = 4161;
            i4 = 4097;
        }
        if (this.ॱॱ == 0) {
            return this.ॱᐝ.ॱ(i, i2, i3, i4);
        }
        return this.ॱˋ.ॱ(i, i2, i3, i4);
    }

    public View ˎ(View view, int i, o oVar, t tVar) {
        ˎ();
        if (ˈ() == 0) {
            return null;
        }
        int ʽ = ʽ(i);
        if (ʽ == Integer.MIN_VALUE) {
            return null;
        }
        View ˋॱ;
        View ॱʽ;
        ᐝ();
        ᐝ();
        ॱ(ʽ, (int) (0.33333334f * ((float) this.ᐝ.ʻ())), false, tVar);
        this.ˏ.ॱॱ = Integer.MIN_VALUE;
        this.ˏ.ˋ = false;
        ॱ(oVar, this.ˏ, tVar, true);
        if (ʽ == -1) {
            ˋॱ = ˋॱ(oVar, tVar);
        } else {
            ˋॱ = ʻ(oVar, tVar);
        }
        if (ʽ == -1) {
            ॱʽ = ॱʽ();
        } else {
            ॱʽ = ـ();
        }
        if (!ॱʽ.hasFocusable()) {
            return ˋॱ;
        }
        if (ˋॱ == null) {
            return null;
        }
        return ॱʽ;
    }

    public boolean ˏ() {
        return this.ˊॱ == null && this.ˊ == this.ˎ;
    }

    @RestrictTo({androidx.annotation.RestrictTo.d.ˊ})
    public void ˋ(@NonNull View view, @NonNull View view2, int i, int i2) {
        ˎ("Cannot drop a view during a scroll or layout calculation");
        ᐝ();
        ˎ();
        int ˎ = ˎ(view);
        int ˎ2 = ˎ(view2);
        if (ˎ < ˎ2) {
            Object obj = 1;
        } else {
            ˎ = -1;
        }
        if (this.ˏॱ) {
            if (obj == 1) {
                ॱ(ˎ2, this.ᐝ.ˊ() - (this.ᐝ.ˋ(view2) + this.ᐝ.ˊ(view)));
            } else {
                ॱ(ˎ2, this.ᐝ.ˊ() - this.ᐝ.ॱ(view2));
            }
        } else if (obj == -1) {
            ॱ(ˎ2, this.ᐝ.ˋ(view2));
        } else {
            ॱ(ˎ2, this.ᐝ.ॱ(view2) - this.ᐝ.ˊ(view));
        }
    }
}
